<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>接收 Server-Sent 事件通知</title>
</head>
<body>

<h1>获得服务器更新</h1>

<div id="result"></div>

<script>
  if (typeof(EventSource) !== "undefined")
  {
    var source = new EventSource("demo_sse.php");
    source.onmessage = function (event)
    {
        document.getElementById("result").innerHTML += event.data + "<br />";
    };
  }
  else
  {
      document.getElementById("result").innerHTML = "抱歉，您的浏览器不支持 server-sent 事件 ...";
  }
</script>

</body>
</html>